var regioni = document.getElementById("regionValue").value;
var provincei = document.getElementById("provinceValue").value;
var citiesi = document.getElementById("citiesValue").value;
var oneChanneli = document.getElementById("oneChannelValue").value;
var twoChanneli = document.getElementById("twoChannelValue").value;
var thrChanneli = document.getElementById("thrChannelValue").value;
var oneMediumi = document.getElementById("oneMediumValue").value;
var twoMediumi = document.getElementById("twoMediumValue").value;
var thrMediumi = document.getElementById("thrMediumValue").value;
var ChannelList;
var MediumList;
oneChanneli = "直接上门";
$.post(Feng.ctxPath + "/channel/getChannelsss", function (data) {//初始化下拉渠道列表
    ChannelList = data;
    channelInit('oneChannel', 'twoChannel', 'thrChannel');
    $("#oneChannel").attr("disabled", true).css('background','#ebebe4');
    $("#twoChannel").attr("disabled", true).css('background','#ebebe4');
    $("#thrChannel").attr("disabled", true).css('background','#ebebe4');
}, "json");
$.post(Feng.ctxPath + "/medium/getMedium", function (data) {//初始化下拉媒介列表
    MediumList = data;
    mediumInit('oneMedium', 'twoMedium', 'thrMedium');
}, "json");
addressInit('province', 'cities', 'region');

$("#birthday").on("input",function () {
    var resbirthday=/^(19\d\d|20\d\d)[-/ ](0\d|1[0-2])[-/ ](0\d|[1-2]\d|30|31)$/;
    var birthday = $("#birthday").val();
    if(birthday.length > 0 && birthday.length < 4 ){
    }else if(birthday.length >= 4 && birthday.length < 10){
        var s = birthday.substring(0,4);
        if(!isNaN(s)){
            var data = new Date();
            $("#customerAge").val(data.getFullYear() - s)
        }
    }else {
        if(resbirthday.test(birthday)){
            var birthDayTime = new Date(birthday).getTime();
            var nowTime = new Date().getTime();
            $("#customerAge").val(Math.ceil((nowTime - birthDayTime) / 31536000000))
        }else {
            Feng.error("请输入正确的格式！")
        }
    }
});

$("#customerAge").on('input',function(){//输入年龄出生日期显示
    var date = new Date();
    var currentYear = date.getFullYear()-$("#customerAge").val();
    $("#birthday").val(currentYear + "-01-01")
});